

var Dialog = (function(){

    var $contextMenu = $("#contextMenu");
    var $tips = $("#tips");

    function timer(callback,time){
        time || (time = 300);
        if(timer.hander){
            clearTimeout(timer.hander);
        }
        timer.hander = setTimeout(function(){
            callback();
            clearTimeout(timer.hander);
            timer.hander = "";
        },time);
    }

    var mask = (function(){
        var $el = $('<div id="mask">');
        var $body = $('body');
        $el.html('<img src="" />');
        return {
            open:function(){
                $body.append($el);
                $el.find("img").attr("src","./assets/img/loading.gif");
            },
            close:function(){
                $el.remove();
            }
        }
    }())

    var tips = (function(){
        var $el = $('<div id="dialog_confirm">');
        var $body = $('body');
        $el.html(`
            <div class="box">
                <div class="content"></div>
                <div class="button">
                    <button class="cancel">确定</button>
                </div>
            </div>
        `);
        $el.on("click",".cancel",function(){
            tips.close();
        })
        return {
            open:function(name){
                $el.find(".content").html('<text class="w_1">'+name+'</text>');
                $body.append($el);
            },
            close:function(){
                $el.remove();
            }
        }
    }())

    return {
        hideMenu:function(){},
        mask:mask,
        tips:tips
    }

}())